home *** CD-ROM | disk | FTP | other *** search
/ Aminet 32 / Aminet 32 (1999)(Schatztruhe)[!][Aug 1999].iso / Aminet / dev / lang / Python151_Src.lha / Python1.5_Source / Amiga / perror.c < prev    next >
C/C++ Source or Header  |  1994-09-30  |  1KB  |  58 lines

  1. RCS_ID_C = "$Id: perror.c,v 4.1 1994/09/29 23:09:02 jraja Exp $";
  2. /*
  3.  *      perror.c - print error message
  4.  *
  5.  *      Copyright © 1994 AmiTCP/IP Group, 
  6.  *                       Network Solutions Development Inc.
  7.  *                       All rights reserved.
  8.  */
  9.  
  10. /****** net.lib/perror *******************************************************
  11.  
  12.     NAME
  13.         perror - socket error messages
  14.  
  15.     SYNOPSIS
  16.         extern int errno;
  17.  
  18.         #include <stdio.h>
  19.  
  20.         perror(banner)
  21.         void perror(const char *)
  22.  
  23.     FUNCTION
  24.         The perror() function finds the error message corresponding to the
  25.         current value of the global variable errno and writes it, followed
  26.         by a newline, to the stderr. If the argument string is non-NULL it
  27.         is preappended to the message string and separated from it by a
  28.         colon and space (`: '). If string is NULL only the error message
  29.         string is printed.
  30.  
  31.     NOTES
  32.         The perror() function requires the stdio functions to be linked.
  33.  
  34.     SEE ALSO
  35.         strerror(), PrintNetFault(), <netinclude:sys/errno.h>
  36.  
  37. ******************************************************************************
  38. */
  39.  
  40. #include <stdio.h>
  41. #include <errno.h>
  42. #include <string.h>
  43. #include <clib/netlib_protos.h>
  44.  
  45. void 
  46. perror(const char *banner)
  47. {
  48.   const char *err = strerror(errno);
  49.  
  50.   if (banner != NULL) {
  51.     fputs(banner, stderr);
  52.     fputs(": ", stderr);
  53.   }
  54.   fputs(err, stderr);
  55.   fputc('\n', stderr);
  56.   fflush(stderr);
  57. }
  58.